<html>
<head><meta charset="utf-8"><title>Sessions and rustdoc · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html">Sessions and rustdoc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205331587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205331587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205331587">(Jul 29 2020 at 08:53)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> I'm trying to remove <code>SessionGlobals::{known,used}_attrs</code>, by moving them into <code>Session</code></p>



<a name="205331625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205331625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205331625">(Jul 29 2020 at 08:54)</a>:</h4>
<p>I've got a fair way, but have hit a problem - the <code>run()</code> function in <code>librustdoc/html/render.rs</code> doesn't have a <code>Session</code>, but one is needed</p>



<a name="205331688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205331688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205331688">(Jul 29 2020 at 08:54)</a>:</h4>
<p>With the existing code, the global creation is distinct from the Session creation</p>



<a name="205331716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205331716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205331716">(Jul 29 2020 at 08:55)</a>:</h4>
<p>I'm not even sure if the <code>render.rs</code> code really needs the attr known/used stuff</p>



<a name="205351834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205351834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205351834">(Jul 29 2020 at 12:56)</a>:</h4>
<p>rustdoc can probably entirely ignore known/used attrs, so long as it doesn't panic on calling attr::mark_used and such</p>



<a name="205448049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205448049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205448049">(Jul 30 2020 at 07:18)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/74932">https://github.com/rust-lang/rust/pull/74932</a> is the resulting PR</p>



<a name="205448059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205448059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205448059">(Jul 30 2020 at 07:18)</a>:</h4>
<p>I've been looking at <code>rustc_span::SessionGlobals</code>. It is quite a bit harder :(</p>



<a name="205448101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205448101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205448101">(Jul 30 2020 at 07:19)</a>:</h4>
<p>e.g. requiring a <code>Session</code> on hand to call <code>Span::new()</code> or <code>Symbol::intern()</code> is really invasive</p>



<a name="205448860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205448860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205448860">(Jul 30 2020 at 07:30)</a>:</h4>
<p>And there are the places where we only have a <code>ParseSess</code> rather than a <code>Session</code> (e.g. some tests, some parts of rustdoc)</p>



<a name="205472392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205472392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205472392">(Jul 30 2020 at 12:35)</a>:</h4>
<p>rustdoc wants to check for dead attributes</p>



<a name="205472496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205472496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205472496">(Jul 30 2020 at 12:36)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/74098#issuecomment-665789015">https://github.com/rust-lang/rust/pull/74098#issuecomment-665789015</a></p>



<a name="205472506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205472506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205472506">(Jul 30 2020 at 12:36)</a>:</h4>
<p>so they can't be removed completely</p>



<a name="205472525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205472525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205472525">(Jul 30 2020 at 12:36)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> is working on a PR fixing the current broken behavior, I would wait until he finishes that</p>



<a name="205504159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205504159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205504159">(Jul 30 2020 at 16:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120989">njn</span> <a href="#narrow/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc/near/205448101">said</a>:</p>
<blockquote>
<p>e.g. requiring a <code>Session</code> on hand to call <code>Span::new()</code> or <code>Symbol::intern()</code> is really invasive</p>
</blockquote>
<p>Yeah, that's why the TLS-based access to the session have to be provided from the start.</p>



<a name="205504272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205504272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205504272">(Jul 30 2020 at 16:59)</a>:</h4>
<p>Not only to serve <code>Debug</code> impls and such, but also to make the migration realistic.</p>



<a name="205504651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205504651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205504651">(Jul 30 2020 at 17:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120989">njn</span> <a href="#narrow/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc/near/205448860">said</a>:</p>
<blockquote>
<p>And there are the places where we only have a <code>ParseSess</code> rather than a <code>Session</code> (e.g. some tests, some parts of rustdoc)</p>
</blockquote>
<p>Globals can live in <code>ParseSess</code> as well, or in some new session type if necessary.<br>
(I still haven't investigated this enough to make more detailed suggestions.)</p>



<a name="205543042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205543042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205543042">(Jul 30 2020 at 23:10)</a>:</h4>
<p>I have avoided using <code>ParseSess</code> because I don't understand its lifetimes well. A <code>ParseSess</code> can be created in lots of places that a <code>Session</code> is not, and I'm scared of e.g. ending up with two symbol tables and then having bogus comparisons made between symbols from different tables.</p>



<a name="205543665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205543665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205543665">(Jul 30 2020 at 23:18)</a>:</h4>
<p>In general, the <code>SessionGlobals</code> annoy me. Their setup and structure is complex and confusing. Plus we have the ImplicitContext stuff, which is also complex and confusing. Plus TLS accesses are slow. If we must have implicit access it would be better to have a single mechanism.</p>



<a name="205543746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205543746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205543746">(Jul 30 2020 at 23:19)</a>:</h4>
<p><code>SessionGlobals::source_map</code> is a prime example of the messiness here. When printing a span, we look for a source map in the ImplicitCtxt if it's available. Failing that, we fall back to any source map that might be in <code>SessionGlobals</code>. Failing that, we print it raw.</p>



<a name="205543840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205543840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205543840">(Jul 30 2020 at 23:20)</a>:</h4>
<p>I still haven't got my head around the ImplicitCtxt stuff. All those <code>enter_context</code> and <code>enter_global</code> and <code>with_global</code> functions</p>



<a name="205543963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Sessions%20and%20rustdoc/near/205543963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Sessions.20and.20rustdoc.html#205543963">(Jul 30 2020 at 23:22)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> It seems like you have strong opinions here. I'd be happy to hear your ideas for a re-design. <a href="https://github.com/rust-lang/rust/issues/74932">#74932</a> is me dabbling in this stuff</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>